using System;
using System.Collections.Generic;
using System.Text;

using IBatisNet.DataMapper.TypeHandlers;
using RaisingStudio.Data.Entities;

namespace PerformanceTest
{
    public class IssueTypeTypeHandler : ITypeHandlerCallback
    {
        #region ITypeHandlerCallback Members

        public object GetResult(IResultGetter getter)
        {
            if (getter.Value != DBNull.Value)
            {
                return (IssueType)Enum.Parse(typeof(IssueType), getter.Value as string);
            }
            else
            {
                return null;
            }
        }

        public object NullValue
        {
            get
            {
                return null;
            }
        }

        public void SetParameter(IParameterSetter setter, object parameter)
        {
            setter.DataParameter.DbType = System.Data.DbType.Int32;
            if (parameter != null)
            {
                setter.Value = (int)parameter;
            }
            else
            {
                setter.Value = DBNull.Value;
            }
        }

        public object ValueOf(string s)
        {
            int i = int.Parse(s);
            return (IssueType)i;
        }

        #endregion
    }
}
